﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;

namespace Global.Helpers
{
    public static class GamaOptions
    {
        //Key
        public const string LanguageKey = "Language";
        public const string PathToImagesKey = "PathToImages";
        public const string PathToeBookImagesKey = "PathToeBookImages";
        public const string PathToLayoutImagesKey = "PathToLayoutImages";
        public const string PathToPromoImagesKey = "PathToPromoImages";
        public const string PathToMediaKey = "PathToMedia";
        public const string PathToStylesKey = "PathToStyles";
        public const string PathToScriptsKey = "PathToScripts";
        public const string ResizedImageFolderKey = "ResizedImageFolder";
        public const string OptionNoImageFileNameKey = "OptionNoImageFileName";
        public const string PathToProductImagesKey = "PathToProductImages";
        public const string OptionImageFolderKey = "OptionImageFolder";
        public const string CookieTimeoutInDaysKey = "CookieTimeoutInDays";
        public const string StaticComponentVersionKey = "StaticComponentVersion";
        public const string GuestIdKey = "GuestId";
        //End key
        public static string PathToImages { get; set; }
        public static string PathToProductImages { get; set; }
        public static string PathToeBookImages { get; set; }
        public static string PathToLayoutImages { get; set; }
        public static string PathToPromoImages { get; set; }
        public static string PathToStyles { get; set; }
        public static string PathToScripts { get; set; }
        public static string PathToMedia { get; set; }
        public static string LanguageDefault { get; set; }
        public static int CookieTimeoutInDays { get; set; }
        private static string ResourceVersion { get; set; }
        static GamaOptions()
        {
            LanguageDefault = GetAppSettingValueOrDefault(LanguageKey, "en-US");
            PathToImages = GetAppSettingValueOrDefault(PathToImagesKey, "~/");
            PathToProductImages = GetAppSettingValueOrDefault(PathToProductImagesKey, "~/");
            PathToeBookImages = GetAppSettingValueOrDefault(PathToeBookImagesKey, "~/");
            PathToLayoutImages = GetAppSettingValueOrDefault(PathToLayoutImagesKey, "~/");
            PathToPromoImages = GetAppSettingValueOrDefault(PathToPromoImagesKey, "~/");
            PathToMedia = GetAppSettingValueOrDefault(PathToMediaKey, "~/");
            PathToStyles = GetAppSettingValueOrDefault(PathToStylesKey, "~/");
            PathToScripts = GetAppSettingValueOrDefault(PathToScriptsKey, "~/");
            CookieTimeoutInDays = int.Parse(GetAppSettingValueOrDefault(CookieTimeoutInDaysKey, "365"));
            ResourceVersion = GamaOptions.GetAppSettingValueOrDefault(GamaOptions.StaticComponentVersionKey, "1");
        }       
        public static string GetAppSettingValueOrDefault(string key, string @defaultValue)
        {
            return System.Configuration.ConfigurationManager.AppSettings.AllKeys.Contains(key) ? System.Configuration.ConfigurationManager.AppSettings[key] : @defaultValue;
        }
        public static Dictionary<string, string> _Languages;
        public static Dictionary<string, string> Languages
        {
            get
            {
                if (_Languages == null || _Languages.Count == 0)
                {
                    _Languages = new Dictionary<string, string>();
                    _Languages.Add("en-us", "en-us");
                    _Languages.Add("fr-fr", "fr-fr");
                    _Languages.Add("zh-cn", "zh-cn");
                    _Languages.Add("es-es", "es-es");
                    _Languages.Add("hi-in", "hi-in");
                    _Languages.Add("de-de", "de-de");
                    _Languages.Add("id-id", "id-id");
                }
                return _Languages;
            }
        }
    }
}
